<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>用户-${easySystem.name} ${easySystem.version}</title>
<#include "/templates/common/admin_head.ftl">
</head>
<body>
	<form action="${base}/admin/user_list" method="post" name="listForm">
		<table class="action">
			<tr>
				<td class="title">管理员管理</td>
				<td>
					<ul class="action_ct">
						<li><a id="action_list" href="${base}/admin/user_list"><em class="ico-list"></em>&nbsp;列表</a></li>
						<li><a id="action_search" href="javascript:;"><em class="ico-search"></em>&nbsp;搜索</a></li>
						<li><a id="action_add" href="${base}/admin/user_input"><em class="ico-add"></em>&nbsp;添加</a></li>
						<li><a id="action_edit" href="javascript:;" url="${base}/admin/user_input?id="><em class="ico-edit"></em>&nbsp;编辑</a></li>
					</ul>
				</td>
			</tr>
		</table>

		<div class="line">&nbsp;</div>
		<!-- Content -->
		<table class="table_list">
			<tr class="title">
				<td width="20" class="check_box"><a href="javascript:;" class="check_all"></a></td>
				<td>姓名</td>
				<td>邮箱</td>
				<td>手机</td>
				<td>用户名</td>
				<td>锁定</td>
				<td>启用</td>
				<td>用户类型</td>
				<td>创建时间</td>
				<td>创建人</td>
				<td>修改时间</td>
				<td>修改人</td>
			</tr>
			<tbody>
				<#list page.list as item>
				<tr>
					<td><input type="checkbox" name="key" value="${item.id}" /></td>
					<td>${(item.name)!"&nbsp;"}</td>
					<td>${(item.email)!"&nbsp;"}</td>
					<td>${(item.mobile)!"&nbsp;"}</td>
					<td>${(item.username)!"&nbsp;"}</td>
					<td><a title="${(item.isLocked??&&item.isLocked)?string('点击解锁','点击锁定')}" href="javascript:;">&nbsp;<#if item.isLocked??&&item.isLocked> <em class="ico-locked"></em> <#else> <em class="ico-unlocked"></em> </#if>&nbsp;</a></td>
					<td><a title="${(item.userEnable??&&item.userEnable)?string('点击禁用','点击启用')}" href="javascript:;">&nbsp;<#if item.userEnable??&&item.userEnable> <em class="ico-enable"></em> <#else> <em class="ico-disable"></em> </#if>&nbsp;</a></td>
					<td>${enumTool.valueOf('com.easy.admin.enums.UserType',item.userType).desc}</td>
					<td>${item.createTime?string('yyyy-MM-dd HH:mm:ss')}</td>
					<td>${(item.createUser)!"&nbsp;"}</td>
					<td>${item.modifyTime?string('yyyy-MM-dd HH:mm:ss')}</td>
					<td>${(item.modifyUser)!"&nbsp;"}</td>
				</tr>
				</#list>
			</tbody>
		</table>
		<#include "/templates/common/page.ftl">
		<!-- search -->
		<table class="search_box display_n">
			<tr>
				<td class="w80 text_r">关键字:</td>
				<td><input type="text" name="keyword" maxlength="20" class="input w150" value="${page.criteria.keyword!''}"/></td>
			</tr>
		</table>
	</form>
	<script type="text/javascript">
		$(document).ready(function(){
			//表格颜色
			$('table.table_list tbody').easy_table_color();
			$('#action_search').easy_search();
			$('#action_edit').easy_edit();
			
			//锁定、解锁
			$("em.ico-locked,em.ico-unlocked").parent().click(function(){
				var _this = this;
				var isLocked = $(_this).find("em").hasClass("ico-locked");
				var id = $(_this).parent().siblings().find("input[name='key']:first").val();
				$.ajax({
                    url: '${base}/admin/user_switch_lock',
                    data: {id:id},
                    dataType: "json",
                    type: "post",
                    async: false,
                    success: function (data) {
                        if (data.success) {
                        	if(isLocked){
                        		$.easy.success("解锁成功");
                            	$(_this).find("em").addClass("ico-unlocked").removeClass("ico-locked");
                        	}
                        	else{
                        		$.easy.success("锁定成功");
                            	$(_this).find("em").removeClass("ico-unlocked").addClass("ico-locked");
                        	}
                        }
                        else if(data.denied){
                        	$.easy.fail("没有权限!");
                        }
                        else{
                       		$.easy.fail("操作失败!"+data.message);
                        }
                    }
                });
			});
			
			//禁用启用
			$("em.ico-enable,em.ico-disable").parent().click(function(){
				var _this = this;
				var enable = $(_this).find("em").hasClass("ico-enable");
				var id = $(_this).parent().siblings().find("input[name='key']:first").val();
				$.ajax({
                    url: '${base}/admin/user_switch_enable',
                    data: {id:id},
                    dataType: "json",
                    type: "post",
                    async: false,
                    success: function (data) {
                        if (data.success) {
                        	if(enable){
                        		$.easy.success("禁用成功");
                            	$(_this).find("em").addClass("ico-disable").removeClass("ico-enable");
                        	}
                        	else{
                        		$.easy.success("启用成功");
                            	$(_this).find("em").removeClass("ico-disable").addClass("ico-enable");
                        	}
                        }
                        else if(data.denied){
                        	$.easy.fail("没有权限!");
                        }
                        else{
                       		$.easy.fail("操作失败!"+data.message);
                        }
                    }
                });
			});
			
		});
	</script>
</body>
</html>